<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class TB_Menu extends CI_Model {	
	function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

	function Insert()
	{
			$MenuEnt=array("ClassID"=>$_POST["ClassID"], "TypeID"=>$_POST["TypeID"],
			"ClassName"=>$_POST["ClassName"],"TypeName"=>$_POST["TypeName"]);
		$this->db->insert('tb_menu', $MenuEnt); 
	}
	function Update($MenuEnt)
	{
		$this->db->update('tb_menu', $MenuEnt,array('ClassID' => $_GET['ClassID']));
	
	}
	function delete($ClassID)
	{
		$this->db->delete('tb_menu',array('ClassID' => $ClassID));
	
	}
	function get_Menus()
	{
			$query=$this->db->get('TB_Menu');
			return $query->result();
	}
	function get_Menu_OneRow($ClassID,$TypeID)
	{
		$sql = "SELECT *
    	FROM TB_Menu WHERE ClassID = ? and TypeID= ? "; 
		$query =$this->db->query($sql, array($ClassID,$TypeID));
        return $query->result();
	}
	function get_TypeByClassID($ClassID)
	{
		$sql = "SELECT TypeID,TypeName
    	FROM TB_Menu WHERE ClassID = ?"; 
		$query =$this->db->query($sql, array($ClassID));
        return $query->result();
	}
}
?>